(function (angular) {
  var myApp = angular.module("loginApp", ["userService"]);
  myApp.controller("loginController", function ($scope, myService) {
    //初始化
    $scope.user.name=null;
    $scope.user.password=null;
    $scope.user = {
      name: null,
      password: null
    }

    /**
     * 登录
     * @param usert
     */
    $scope.login_t = function () {
      if($scope.user.name==null){
        /*layer.alert('用户名称不能为空');*/
        alert("用户名称不能为空");
        return;
      }
      if($scope.user.password==null){
        alert("密码不能为空");
        return;
      }
      myService.queryUser({
        user_account: $scope.usert.user_account,
        user_pwd: $scope.usert.user_pwd,
        user_role: 0
      }).success(function (data) {
        if (data.success) {
          $scope.usert = "";
          //跳转其他页面
          window.location.href = "/user/teacher.do"
        } else {
          layer.msg('账号或密码错误,请重新登录');
          $scope.usert = "";
        }

      });
    }
    /**
     * 回车键事件
     * @param e
     */
    /*  $scope.myKeyup = function (e) {

          //IE 编码包含在window.event.keyCode中，Firefox或Safari 包含在event.which中
          var keycode = window.event ? e.keyCode : e.which;
          if (keycode == 13) {
              $scope.login_t();
          }
      };
*/
  });
})(angular)
